<?php
/**
 * CompleXml Framework
 *
 * @category   CompleXml
 * @package    CompleXml_Object_Controller_Template
 * @copyright  Copyright (c) 2008 Andrey Kucherenko
 * @license    New BSD License
 * @version    0.1
 */
require_once 'CompleXml/Object/Controller.php';

class CompleXml_Object_Controller_Template_Zend extends CompleXml_Object_Controller
{

	public function proccess($controllers_dir, $templates_path,  $locate)
	{
		$this->setControllerPath($controllers_dir);
		
		$page = $this->Request->Uri->getString(0, 'index');

		if ($page[0]=='?'){
			$page = 'index';
		}
		
		$action = $this->Request->Uri->getString(1, 'index');

		$conroller = ucfirst($page).'Page';

		$template = $templates_path.DIRECTORY_SEPARATOR.strtolower($page).DIRECTORY_SEPARATOR.strtolower($action);

		if (isset($_SERVER[ 'HTTP_X_REQUESTED_WITH' ])){
			require_once 'CompleXml/Handler/Output/Xml.php';
			$xmlOutputHandler = new CompleXml_Handler_Output_Xml();
			$handlers = array($xmlOutputHandler);
		}else{
			require_once 'CompleXml/Handler/Output/Xslt.php';
			$xslOutputHandler = new CompleXml_Handler_Output_Xslt();
			$xslOutputHandler->setIsDebug($this->Request->getBool('xml'));
			$handlers = array($xslOutputHandler);
		}

		$actions = array($action.'Action');

		$this->start($conroller, $actions, $template, $handlers, $locale);

	}

}